package cn.grf.datasource.controller;

import cn.grf.datasource.pojo.Account;
import cn.grf.datasource.service.AccountService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author grf
 * @apiNote
 * @since 2025/5/6
 */
@RestController
@RequestMapping("/account")
@RequiredArgsConstructor
public class AccountController {

    private final AccountService accountService;

    @PostMapping
    public void insert(Account account) {
        accountService.insert(account);
    }

    @GetMapping("/list")
    public List<Account> list() {
        return accountService.list();
    }

    @GetMapping
    public Account get(Long id) {
        return accountService.get(id);
    }
}
